This page last changed on Feb 27, 2009 by stepheneb.

In February 2009 we added the jres protocol for accessing resources such as scripts and images stored in jars.

See: Adding new URL protocols in Java for a technical overview of the implementation.

Resources such as scripts and images can be referenced in otml using urls of various types.

When normal relative and absolute references are evaluated the resource is loaded from the file system or over the network. If the network is slow (which can easily happen in a school) loading resources on remote networks can easily cause performance problems.

The jres protocol supports accessing resources from the Java class path. This means that if these resources are included in the signed jars delivered by Java Web Start that they will only be downloaded once when the application is first installed on the users computer. Subsequent access will retrieve the resource from a jar file on the users local file system.

Relative reference:

  • Images
    <OTImage imageBytes="images/red-box-zoom-1-sm.png" />
    
  • Scripts
    <OTJRuby src="scripts/smart_graph_label_script_template.rb">
    

Absolute references:

  • Images
    <OTImage imageBytes="http://continuum.concord.org/otrunk/examples/UDL/images/red-box-zoom-1-sm.png" />
    
  • Scripts
    <OTJRuby src="https://svn.concord.org/svn/projects/trunk/common/java/otrunk/otrunk-examples/UDL/scripts/smart_graph_label_script_template.rb">
    

Absolute references scoped to the Java classpath using the jres:// protocol

  • Images
    • XHTML inside a bodyText element:
      <img src="jres:///org/concord/otrunk/udl/document/blah-anim.gif" height="150" width="200" />
      
    • OTUDLCoach object
      <OTUDLCoach inactiveImageURL="jres:/org/concord/otrunk/udl/document/blah-head.png"
       activeImageURL="jres:/org/concord/otrunk/udl/document/blah-anim.gif" />
      
  • Scripts
    • Javascript:
      <OTJavascript src="jres:///org/concord/otrunk/udl/scripts/change_page.js" />
      
    • JRuby:
      <OTJRuby src="jres:/org/concord/smartgraph/scripts/otrunk_ruby_script_tools.rb" />
      
  • OTML documents
    <OTInclude href="jres:/org/concord/otrunk/udl/imports/udl-view-bundle.otml" />
    
  • Text resources
    <OTDefinitionList src="jres:/org/concord/otrunk/udl/glossary/common-glossary.txt" />
    

Examples of embedding resources into Java projects that are delivered as signed jars

These resources are included in data-util.jar:

While these resources which are used only for the UDL project are included in otrunk-udl.jar:


Document generated by Confluence on Jan 27, 2014 16:52